package view;

import javax.swing.JPanel;

import model.Location;


/**
 * This class represents an individual tile on the board.
 * Each BoardPanel knows its own location, what is on it presently, and if it is highlighted or not.
 * @author Ben
 */
@SuppressWarnings("serial")
public class BoardPanel extends JPanel
{
	/**
	 * The Location of this BoardPanel.
	 */
	private Location id;
	
	/**
	 * The Integer representation of the piece on this BoardPanel
	 */
	private int piece;
	
	/**
	 * The color, if any, of the piece on this BoardPanel
	 */
	private int color;
	
	/**
	 * The boolean representing if this BoardPanel is currently highlighted or not.
	 */
	private boolean highlighted;

	/**
	 * The barebones constructor for a BoardPanel, initializing it with a given location that should never change.
	 * @param id - Location for the BoardPanel to be set to.
	 */
	public BoardPanel(Location id)
	{
		this.id = id;
	}
	
	/**
	 * @return the grid location of this BoardPanel
	 */
	public Location getGridLocation()
	{
		return id;
	}
	
	/**
	 * Sets the piece of the this BoardPanel
	 * @param piece - Integer representation of piece to be set.
	 * @param color - Integer representation of color of piece to be set.
	 */
	protected void setPiece(int piece, int color) {
		this.piece = piece;
		this.color = color;
	}
	
	/**
	 * 
	 * @return - An int[] holding both the piece and color on this BoardPanel.
	 */
	protected int[] getPiece() {
		return new int[] {piece, color};
	}
	
	/**
	 * Sets the color of this BoardPanel
	 * @param color - color to be set
	 */
	protected void setColor(int color) {
		this.color = color;
	}

	/**
	 * 
	 * @return boolean representing if this BoardPanel is highlighted or not.
	 */
	protected boolean isHighlighted() {
		return highlighted;
	}
	
	/**
	 * 
	 * @param highlighted - boolean that sets highlighting for this panel.
	 */
	protected void setHighlight(boolean highlighted) {
		this.highlighted = highlighted;
	}
}
